#[derive(RustcDecodable)]
struct Options {
+ flag_target: Option<String>,
flag_features: Vec<String>,
flag_jobs: Option<u32>,
flag_manifest_path: Option<String>,
-j N, --jobs N The number of jobs to run in parallel
--features FEATURES Space-separated list of features to also build
--no-default-features Do not build the `default` feature
+ --target TRIPLE Build for the target triple
--manifest-path PATH Path to the manifest to document
-v, --verbose Use verbose output
compile_opts: ops::CompileOptions {
config: config,
jobs: options.flag_jobs,
- target: None,
+ target: options.flag_target.as_ref().map(|t| &t[..]),
features: &options.flag_features,
no_default_features: options.flag_no_default_features,
spec: options.flag_package.as_ref().map(|s| &s[..]),
fn rustdoc(package: &Package, target: &Target, profile: &Profile,
cx: &mut Context) -> CargoResult<Work> {
let kind = Kind::Target;
- let cx_root = cx.get_package(cx.resolve.root()).absolute_target_dir()
- .join("doc");
+ let mut doc_dir = cx.get_package(cx.resolve.root()).absolute_target_dir();
let mut rustdoc = try!(process(CommandType::Rustdoc, package, target, cx));
rustdoc.arg(&root_path(cx, package, target))
.cwd(cx.config.cwd())
- .arg("-o").arg(&cx_root)
.arg("--crate-name").arg(&target.crate_name());
+ if let Some(target) = cx.requested_target() {
+ rustdoc.arg("--target").arg(target);
+ doc_dir.push(target);
+ }
+
+ doc_dir.push("doc");
+
+ rustdoc.arg("-o").arg(&doc_dir);
+
match cx.resolve.features(package.package_id()) {
Some(features) => {
for feat in features {
assert_that(p.cargo_process("doc"),
execs().with_status(0));
});
+
+test!(doc_target {
+ const TARGET: &'static str = "arm-unknown-linux-gnueabihf";
+
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.0.1"
+ authors = []
+ "#)
+ .file("src/lib.rs", r#"
+ #![feature(no_std)]
+ #![no_std]
+
+ extern {
+ pub static A: u32;
+ }
+ "#);
+
+ assert_that(p.cargo_process("doc").arg("--target").arg(TARGET).arg("--verbose"),
+ execs().with_status(0));
+ assert_that(&p.root().join(&format!("target/{}/doc", TARGET)), existing_dir());
+ assert_that(&p.root().join(&format!("target/{}/doc/foo/index.html", TARGET)), existing_file());
+});